package fr.imag.m2pgi.m2m.geoloc.mqtt.publisher;

import java.util.HashMap;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

public class Activator implements BundleActivator {

  private ServiceRegistration<PublishService> service;
  PublishService pub;
  
  public void start(BundleContext context) throws Exception {
    System.out.println("Starting Publisher bundle...");
    //TODO: get property
    String server = "127.0.0.1";
    int port = 1883;
    pub = new Publisher(server, port);
    service = context.registerService(PublishService.class, pub, null);
    System.out.println("Publisher service registered.");    
  }

  public void stop(BundleContext context) throws Exception {
    //pub.disconnect();
    service.unregister();
  }
  
}
